package com.pinyoumei.app.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.R;
import com.pinyoumei.app.activity.wallet.UserBalanceBean;
import com.pinyoumei.app.activity.wallet.WithdrawalObviousBean;

import java.util.List;

public class withdrawalObviousAdapter extends BaseQuickAdapter<WithdrawalObviousBean.WithdrawalObviousDto, BaseViewHolder> {
    private Context context;
    private int type;
    public withdrawalObviousAdapter(int layoutResId, @Nullable List<WithdrawalObviousBean.WithdrawalObviousDto> data) {
        super(layoutResId, data);
    }

    public void getContext(Context context){
        this.context = context;
    }

    public void getInputType(int type){
        this.type = type;
    }

//    `status` smallint(1) DEFAULT '0' COMMENT '提现状态 0待审核 1提现成功 2提现失败', 3 打款中
//    `withdraw_type` smallint(1) DEFAULT '1' COMMENT '提现板块:1拼团余额 2团队佣金 3返利佣金',
//    `withdraw_out_type` smallint(1) DEFAULT '1' COMMENT '提现到账方式 1支付宝 2微信', 3 银行

    @Override
    protected void convert(BaseViewHolder helper, WithdrawalObviousBean.WithdrawalObviousDto item) {
        helper.setText(R.id.ubi_iv_time,item.getWithdraw_time());
        helper.setText(R.id.ubi_iv_money, "-" + item.getWithdraw_amount());

        String titleTxt = "";
        if(TextUtils.equals(item.getWithdraw_type(),"1")){
            helper.setText(R.id.ubi_iv_title,"余额申请提现");
            helper.setImageDrawable(R.id.ubi_iv_icon, context.getResources().getDrawable(R.mipmap.icon_srtx));
        }else if(TextUtils.equals(item.getWithdraw_type(),"2")){
            helper.setText(R.id.ubi_iv_title,"团队佣金申请提现");
            helper.setImageDrawable(R.id.ubi_iv_icon, context.getResources().getDrawable(R.mipmap.icon_uksqtx));
        }else if(TextUtils.equals(item.getWithdraw_type(),"3")){
            helper.setText(R.id.ubi_iv_title,"返利佣金申请提现 ");
            helper.setImageDrawable(R.id.ubi_iv_icon, context.getResources().getDrawable(R.mipmap.icon_flyjsqtx));
        }

        int txtColor = 0;
        if (TextUtils.equals(item.getStatus(),"0")){
            helper.setText(R.id.ubi_iv_money_type, "待审核");
            txtColor = R.color.color_f88128;
        }else if (TextUtils.equals(item.getStatus(),"1")){
            helper.setText(R.id.ubi_iv_money_type, "已成功");
            txtColor = R.color.loan_select_text_color;
        }else if (TextUtils.equals(item.getStatus(),"2")){
            helper.setText(R.id.ubi_iv_money_type, "已拒绝");
            txtColor = R.color.color_ff0322;
        }else if (TextUtils.equals(item.getStatus(),"3")){
            helper.setText(R.id.ubi_iv_money_type, "打款中");
            txtColor = R.color.color_018d47;
        }

        helper.setTextColor(R.id.ubi_iv_money_type,context.getResources().getColor(txtColor));
    }
}
